package com.xiaoxin.model.vo;

import com.xiaoxin.model.domain.UserInfo;
import com.xiaoxin.model.mongo.RecommendUser;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

/**
 * @author xiaoxiaode
 * @date 2021/9/11 18:15
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class FriendsVo {

    private Integer id;
    private String avatar; //用户头像
    private String nickname; //昵称
    private String gender; //性别
    private Integer age; //年龄
    private String city; //城市
    private String education; //学历
    private Integer marriage; //婚姻状态
    private Integer matchRate; // 推荐值
    private Boolean alreadyLove; // 是否已喜欢

    public static FriendsVo init(UserInfo userInfo, RecommendUser recommendUser) {
        FriendsVo vo = new FriendsVo();
        BeanUtils.copyProperties(userInfo, vo);
        long round = Math.round(recommendUser.getScore());
        vo.setMatchRate(Math.toIntExact(round));
        Integer id=Math.toIntExact(userInfo.getId());
        vo.setId(id);
        return vo;
    }
}
